<?php include_once './application/views/sys_admin/common/header.php';  ?>
<!-- admin_main -->
<div class="admin_main">
	<!-- Admin_top end -->
	<?php include_once './application/views/sys_admin/common/borrow_left.php';  ?>
	<?php 
	$borrow_status = array(
		0=>'待审核',
		1=>'审核通过',
		2=>'审核失败',
	);
	
	$borrow_ftype = array(
		1=>'转入',
		2=>'转出',
	);
	
	?>
	<!-- Admin_Left End -->
	<div class="admin_right">
		<div class="admin_right_title">
			<strong>贷款管理</strong> &gt;&gt;  活利宝  &gt;&gt; 项目列表
		</div>
		
		<div class="admin_right_con" >
			<table border="0" cellspacing="1" cellpadding="0">
			  <tr style="color:#0068b7;">
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>编号</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>用户</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>金额</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>状态</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>信息</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>申请时间</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>审核时间</strong></td>
				<?php if ($borrow['fstatus']==0){?>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>操作</strong></td>
				  <?php }?>
			  </tr>
			  <?php foreach($list as $key=>$borrow){?>
			  <tr>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $borrow['id'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $borrow['username'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo number_format($borrow['money'],2);?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $borrow_status[$borrow['fstatus']];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $borrow['remark'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo date('Y-m-d H:i',$borrow['add_time']);?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF">
				<?php if ($borrow['fstatus']>0){?>
			  <?php echo date('Y-m-d H:i',$borrow['verify_time']);?>
			  	 <?php }?>
			  </td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF">
					<?php if ($borrow['fstatus']==0){?><a href="javascript:;" dataid="<?php echo $borrow['id'];?>" datatype="<?php echo $borrow['ftype'];?>" onclick="gverify(this)">审核</a><?php }else{?>--<?php }?>
				</td>
			  </tr>
			  <?php }?>
			  <tr>
			  	<td colspan="11" align="right">
			  		<form action="/sys_admin/hlb/guardlist/" method="get">
			  			
			  			用户：<input type="text" id="username" name="username" value="<?php echo $where['username'];?>" />
			  			类型：<select id="ftype" name="ftype">
			  			<option value="0">--请选择--</option>
			  				<?php foreach($borrow_ftype as $ftype_key=>$ftype_value){?>
			  				<option value="<?php echo $ftype_key?>" <?php if($where['ftype']==$ftype_key){?>selected="selected"<?php }?>><?php echo $ftype_value;?></option>
			  				<?php }?>
			  			</select>
			  			状态：<select id="fstatus" name="fstatus">
			  			<option value="-1">--请选择--</option>
			  				<?php foreach($borrow_status as $status_key=>$status_value){?>
			  				<option value="<?php echo $status_key?>" <?php if($where['fstatus']==$status_key){?>selected="selected"<?php }?>><?php echo $status_value;?></option>
			  				<?php }?>
			  			</select>
			  			
			  			<input type="submit"/>
			  		</form>
			  	</td>
			  </tr>
			  <tr>
			  	<td colspan="12"  height="35" align="center" valign="middle" bgcolor="#FFFFFF" class="page"><?php echo $this->pagination->create_links();?></td>
			  </tr>
			</table>
			</div>
	</div>
<!-- Admin_Right End -->
</div>
<!-- admin_main end -->

<div id="dialog" title="系统提示" style="display:none;">
<div id="msg" style="text-align:center;color:red">&nbsp;</div>
<input type="hidden" name="gid" id="gid" />
<input type="hidden" name="ftype" id="ftype" />
状态：<input type="radio" name="verify_fstatus" checked="checked" value="1"/>审核通过  <input type="radio" name="verify_fstatus" value="0"/>审核不通过 <br />
<div style="text-align:center;">
<input type="button" value="关闭" onclick="$('#dialog').dialog('close');"/>
<input type="button" value="提交" onclick="withdraw();" />
</div>

</div>
<script>
function gverify(_this){
	var id = $(_this).attr('dataid');
	var ftype = $(_this).attr('datatype');
	if(id>0){
		$( "#dialog" ).dialog({
			height:250,
			width:500,
			modal:true, //蒙层（弹出会影响页面大小）
			title:'活利宝审核'
		});
			
		$( "#gid" ).val(id);
		$( "#ftype" ).val(ftype);
	}
	
}

function withdraw(){
	
	$('#dialog').dialog({
		modal:true,
		title:'系统提示',
	});
	$("#msg").html("正在审核……请耐心等候！");
	
	$.ajax({
		type: "POST",
		url: "/sys_admin/hlb/verify",
		data: "id="+$('#gid').val()+"&fstatus="+$('input[name="verify_fstatus"]:checked').val()+"&ftype="+$( "#ftype" ).val(),
		success: function(msg){
	        $( "#dialog" ).dialog();
			$("#msg").html(msg);
			setTimeout(function(){
				$("#msg").html("&nbsp;");
				if(msg=='操作成功'){
					location.reload();
				}
			},3000);
		},
		dataType: "text"
	});
}


function borrow_check(borrow_id){
	$.ajax({
		type: "post",
		url: "/sys_admin/yjb/borrow_yjb_check/",
		data:"id="+borrow_id,
		success: function(msg){
			if(msg == 1){
				window.location.reload();
			}
		},
		dataType: "text"
	});
	
}

</script>

</body>
</html>
